package com.gaoyu.smarttools.fragmentadapter

import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter

/**
 * Created by ${高宇} on 17/6/5.
 */

/**
 * Created by ${高宇} on 17/4/10.
 * FragmentStatePagerAdapter 可以进行fragment创建和销毁
 */
class FragmentAdapter(
    fm: FragmentManager?,
    private val fragmentList: List<Fragment>,
    private val stringList: List<String>
) : FragmentStatePagerAdapter(
    fm!!
) {
    override fun getItem(position: Int): Fragment {
        return fragmentList[position]
    }

    override fun getCount(): Int {
        return fragmentList.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return stringList[position]
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        return super.instantiateItem(container, position)
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        super.destroyItem(container, position, `object`)
    }
}